<?php
/**
 * Created by PhpStorm.
 * User: yvdedu.com
 * Date: 2019/6/11
 * Time: 11:48
 */

namespace app\api\model;


class SubjectCourseError  extends BaseModel {


    protected $autoWriteTimestamp = true;
    protected $updateTime  = 'update_tiem';

    public function SubjectCourse(){
        return $this->belongsTo('SubjectCourse','course_id','c_id');
    }

    /***
     * @param $cou_id
     * @param $uid
     * @param $car_status
     * @param $course_id
     * @return false|int
     */
    public function InsertSubject($cou_id,$uid,$course_id,$car_status){
        return self::save([
            'false_course'=>$cou_id,
            'user_id'=>$uid,
            'course_id'=>$course_id,
            'car_status'=>$car_status,
            'create_time'=>time()
        ]);
    }

    /*** 查询用户所做错的题目
     * @param $uid
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     *
     */
    public function WrongExercises($uid){
        return self::with('SubjectCourse')->where('user_id',$uid)->select();
    }
}